package lx;

import ls.entity.Student;
import ls.impl.StudentDAOImpl;
import zry.User.Teacher.TeacherDAOImpl;

import java.io.File;
import java.util.List;
import java.util.Scanner;

public class Controller {
    public Controller(){
        File f =new File("d:\\materials");
        f.mkdirs();
    }

    //导师审核学术活动
    public void teacherApproval(String tid){
        Scanner sc=new Scanner(System.in);
        List<String> students=new TeacherDAOImpl().findStudents(tid);
        for(int i=0;i<students.size();i++){
            Student s=new StudentDAOImpl().getStudent(students.get(i));
            System.out.println("姓名："+s.getStudent_name()+"\tID："+s.getStudent_id()+"\t成功认证活动次数："+s.getCommunicate_num());
        }
        System.out.println("请输入需要审核的学生学号");
        String sid=sc.next();
        List<Activities> as=new ActivitiesDAOImpl().getActivities(sid);
        int done_num=0;
        for(int i=0;i< as.size();i++){
            Activities temp=as.get(i);
            if(temp.getActivities_approval_1()==1 && temp.getActivities_approval_2()==1){
                done_num++;
                continue;
            }
            System.out.println(temp.toString());
        }
        if(done_num==as.size()){
            System.out.println("该学生没有未审核的学术交流活动记录");
            return;
        }
        System.out.println("证明材料图片以下载至以下路径");
        System.out.println("d:\\materials");
        System.out.println("请输入要审核的学术活动ID");
        int aid= sc.nextInt();
        System.out.println("您是否同意通过审核y/n");
        String crl= sc.next();
        if(crl.equals("y")||crl.equals("Y"))
            new ActivitiesDAOImpl().approvalActivities_1(true,aid);
        else
            new ActivitiesDAOImpl().approvalActivities_1(false,aid);

    }

    //学科负责人审核
    public void manApproval(){
        Scanner sc=new Scanner(System.in);
        List<Student> students=new StudentDAOImpl().getAllStudent();
        for(int i=0;i<students.size();i++){
            Student s=students.get(i);
            System.out.println("姓名："+s.getStudent_name()+"\tID："+s.getStudent_id()+"\t成功认证活动次数："+s.getCommunicate_num());
        }
        System.out.println("请输入需要审核的学生学号");
        String sid=sc.next();
        List<Activities> as=new ActivitiesDAOImpl().getActivities(sid);
        int done_num=0;
        for(int i=0;i< as.size();i++){
            Activities temp=as.get(i);
            if(temp.getActivities_approval_1()==1 && temp.getActivities_approval_2()==1){
                done_num++;
                continue;
            }
            System.out.println(temp.toString());
        }
        if(done_num==as.size()){
            System.out.println("该学生没有未审核的学术交流活动记录");
            return;
        }
        System.out.println("证明材料图片以下载至以下路径");
        System.out.println("d:\\materials");
        System.out.println("请输入要审核的学术活动ID");
        int aid= sc.nextInt();
        System.out.println("您是否同意通过审核y/n");
        String crl= sc.next();
        if(crl.equals("y")||crl.equals("Y"))
            new ActivitiesDAOImpl().approvalActivities_2(true,aid);
        else
            new ActivitiesDAOImpl().approvalActivities_2(false,aid);
    }

    //学生上传
    public void studentAdd(String sid){
        Scanner sc=new Scanner(System.in);
        Activities a=new Activities();
        System.out.println("请输入学术活动名称");
        a.setActivities_approval_1(2);
        a.setActivities_approval_2(2);
        a.setActivities_name(sc.next());
        System.out.println("请输入学术活动地点");
        a.setActivities_place(sc.next());
        System.out.println("请输入学术活动时间");
        a.setActivities_time(sc.next());
        System.out.println("请输入学术活动报告中英文名称");
        a.setActivities_report(sc.next());
        System.out.println("请输入学术活动证明材料照片路径");
        a.setMaterial_url(sc.next());
        System.out.println("请输入学术活动备注");
        a.setActivities_mes(sc.next());
        a.setStudent_id(sid);
        new ActivitiesDAOImpl().addActivities(a);
    }

    //学术查看自己的审核情况
    public void studentQuery(String sid){

        List<Activities> as=new ActivitiesDAOImpl().getActivities(sid);
        System.out.println("证明材料图片以下载至以下路径");
        System.out.println("d:\\materials");
        for(int i=0;i< as.size();i++){
            Activities temp=as.get(i);
            System.out.println(temp.toString());
        }
    }

    //学生取消学术活动申请
    public void delete(){
        String sid="";
        //todo
        //sid=
        System.out.println("请输入需要删除的学术活动ID");
        Scanner sc=new Scanner(System.in);
        int aid=sc.nextInt();
        new ActivitiesDAOImpl().deleteActivities(aid);
    }
}
